local joyex__qiangxi = fk.CreateSkill {

  name = "joyex__qiangxi",

  tags = {  },

}



joyex__qiangxi:addEffect("active", {
  name = "joyex__qiangxi",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player.hp > 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    if #selected == 0 and player:inMyAttackRange(Fk:currentRoom():getPlayerById(to_select)) then
      return not table.contains(player:getTableMark(  "joyex__qiangxi_targets-phase"), to_select)
    end
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local mark = player:getTableMark(  "joyex__qiangxi_targets-phase")
    table.insertIfNeed(mark, target.id)
    room:setPlayerMark(player, "joyex__qiangxi_targets-phase", mark)
    room:loseHp(player, 1, joyex__qiangxi.name)
    if not player.dead then
      player:drawCards(1, joyex__qiangxi.name)
    end
    if not target.dead then
      room:damage{
        from = player,
        to = target,
        damage = 1,
        skillName = joyex__qiangxi.name,
      }
    end
  end,
})

joyex__qiangxi:addEffect(fk.DamageInflicted, {
  name = "#joyex__qiangxi_trigger",
  mute = true,
  --joyex__qiangxi,
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(joyex__qiangxi.name) and target ~= player and not player:isNude()
  end,
  on_cost = function (self, event, target, player, data)
    local cards = player.room:askForDiscard(player, 1, 1, true, "joyex__qiangxi", true, ".|.|.|.|.|equip", "#joyex__qiangxi-cost:"..target.id, true)
    if #cards > 0 then
      event:setCostData(self, cards)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, { target.id })
    room:throwCard(event:getCostData(self), "joyex__qiangxi", player, player)
    data.damage = data.damage + 1
  end,
})

return joyex__qiangxi